package com.springboot.cloud.sysapps.exam.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.sysapps.exam.form.QuestionForm;
import com.springboot.cloud.sysapps.exam.po.Question;
import com.springboot.cloud.sysapps.exam.service.IQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@RestController
@RequestMapping("/question")
@Api("question")
@Slf4j
public class QuestionController {
    @Resource
    private IQuestionService questionService;
    @ApiOperation(value = "新增题型",notes = "添加试题")
    @ApiImplicitParam(name = "questionForm",value = "添加试题", required = true, dataType = "questionForm")
    @PostMapping
    public Result add(@Valid @RequestBody QuestionForm questionForm){
    log.debug("-----controller add ------"+questionForm);
        Question question =questionForm.toPo(Question.class);
        return Result.success(questionService.add(question));
    }




















}
